<?php

/*

  Treasure	$5

  Worth $1
  When you play this, reveal cards from your deck until you reveal a Treasure. Discard the other cards. Play that Treasure.

 */

class Venture extends Card implements iTreasure, iKingdom, iProsperity {

    public function __construct() {
        parent::__construct("Venture", 5);
        $this->value = new Price(1);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            " Worth $1",
            "When you play this, reveal cards from your deck until you reveal a Treasure. Discard the other cards. Play that Treasure.");
    }

    public function undoParamsPlay($undoParams) {
        return array(false, $undoParams);
    }

    public function autoPlayNum(Game $game) {
        //sholud be dependant on what you have in deck
        return -1;
    }

    public function play(Game $game, $isRealCard) {
        $i = 0;
        $discardCards = array();
        while ($i < 1) {
            $card = $game->peekCardFromDrawDeck();
            if (!$card)
                break;
            if ($card instanceof iTreasure) {
                $drawed_cards = $game->drawCards(1);
                $i+=1;
            } else {
                $card = $game->removeCardFromDrawDeck();
                $discardCards[] = $card;
            }
        }
        if (sizeof($drawed_cards) > 0) {
            $game->pushCardToStack($drawed_cards[0], REAL_CARD, null, false);
            ScreenDisplay::addScreenMessage($game, true, "play " . nicePrint($drawed_cards) . " and discard " . nicePrint($discardCards), "plays " . nicePrint($drawed_cards) . " and discards " . nicePrint($discardCards));
        } else {
            ScreenDisplay::addScreenMessage($game, true, "play no treasures and discard " . nicePrint($discardCards), "plays no treasures and discards " . ScreenDisplay::$LMSG);
        }

        $game->discardTempDiscardCards($discardCards);
        return true;
    }

}

?>